package org.softmed.rest.generation.xml.manager;

import org.softmed.rest.generation.xml.XMLConverterSuite;

import com.google.inject.Inject;
import com.google.inject.name.Named;

public class XMLSuiteManager {

	@Inject
	@Named("DefaultXMLSuiteName")
	static String defaultSuiteName;

	@Inject
	@Named("DefaultXMLSuite")
	static XMLConverterSuite defaultSuite;

	public static synchronized void register(String name,
			XMLConverterSuite suite) {

		GenericToXML.getMarshallers().put(name, suite.getGenericToXML());
		ProcessObjectEdit.getUnmarshallers().put(name,
				suite.getProcessObjectEdit());
		RecoverExistingObjectsUnmarshaller.getUnmarshallers().put(name,
				suite.getRecoverExistingObjects());
	}

	public static synchronized void clear() {
		GenericToXML.getMarshallers().clear();
		ProcessObjectEdit.getUnmarshallers().clear();
		RecoverExistingObjectsUnmarshaller.getUnmarshallers().clear();

		if (defaultSuite != null)
			register(defaultSuiteName, defaultSuite);
	}

}
